<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org/">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <base href="http://localhost/resources/back/">
    <script type="text/javascript" src="lib/jquery/1.9.1/jquery.js"></script>
    <script type="text/javascript" src="js/AjaxUtils.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#add-but").click(function () {
                var name = $("#goodsTypeName").val();
                var pid = $("#pid").val();

                // 判断是否勾选了根节点
                if ($("#isRoot").prop("checked")) {
                    pid = -1;
                }

                var param = new Object();

                param.goodsTypeName = name;
                param.goodsTypePid = pid;
                send("back/goodsTypeController/addGoodsType", param, function (resp) {
                    if (resp.status == "success") {
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    }
                });
            });
        })
    </script>
</head>
<body>
<input type="hidden" id="pid" th:value="${id}">
<input type="checkbox" id="isRoot" value="1">是否根节点<br>
节点名称: <input type="text" name="goodsTypeName" id="goodsTypeName">
<button id="add-but">添加</button>
</body>
</html>